package com.ddai.test.reuse;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

import com.ddai.test.releaseview.R;

public class ReuseTest1Activity extends Activity {

	Button bt1, bt2, bt3;
	ImageView iv1, iv2, iv3;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.reuse1);
		bt1 = (Button) findViewById(R.id.button1);
		bt2 = (Button) findViewById(R.id.button2);
		bt3 = (Button) findViewById(R.id.button3);
		iv1 = (ImageView) findViewById(R.id.imageView1);
		iv2 = (ImageView) findViewById(R.id.imageView2);
		iv3 = (ImageView) findViewById(R.id.imageView3);
		bt1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
//				Bitmap b1 = BitmapFactory.decodeResource(getResources(),
//						R.drawable.aa);
//				iv1.setImageBitmap(b1);
				iv1.setImageResource(R.drawable.aa);
			}
		});
		bt2.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
//				Bitmap b1 = BitmapFactory.decodeResource(getResources(),
//						R.drawable.aa);
//				iv2.setImageBitmap(b1);
				iv2.setImageResource(R.drawable.aa);
			}
		});
		bt3.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
//				Bitmap b1 = BitmapFactory.decodeResource(getResources(),
//						R.drawable.aa);
//				iv3.setImageBitmap(b1);
				iv3.setImageResource(R.drawable.aa);
			}
		});
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		if(item.getTitle().equals("TEST2")){
			Intent intent =new Intent(this, ReuseTest2Activity.class);
			startActivity(intent);
		}
		return true;
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		menu.add("TEST2");
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
